//import 'package:flutter_downloader/flutter_downloader.dart';
//import 'package:path_provider/path_provider.dart';
//import 'package:permission_handler/permission_handler.dart';
//import 'package:flutter_elf/utils/print_utils.dart';
//
//typedef OnDownLoading(String url,String taskId,DownloadTaskStatus status,int progress);
//
//class DownLoaderServices{
//
//  static DownLoaderServices _instance ;
//
//  DownLoaderServices._internal();
//
//
//  static createTask(String url,OnDownLoading onDownLoading)async{
//    if(_instance == null){
//      _instance = DownLoaderServices._internal();
//      await FlutterDownloader.initialize();
//    }
//    await _checkPermission();
//    final directory = await getExternalStorageDirectory();
//    String mTaskId = await FlutterDownloader.enqueue(url: url, savedDir: directory.path,showNotification: false,openFileFromNotification: true);
//    FlutterDownloader.registerCallback(downloadCallback);
//  }
//  static void downloadCallback(String id, DownloadTaskStatus status, int progress) {
//    globalPrint('下载任务' + id);
//    globalPrint('下载进度' + progress.toString());
//    globalPrint('下载状态' + status.value.toString());
//  }
//  static Future<bool> _checkPermission() async {
//    PermissionStatus permission = await PermissionHandler().checkPermissionStatus(PermissionGroup.storage);
//    if (permission != PermissionStatus.granted) {
//      Map<PermissionGroup, PermissionStatus> permissions = await PermissionHandler().requestPermissions([PermissionGroup.storage]);
//      if (permissions[PermissionGroup.storage] != PermissionStatus.granted) {
//        return await PermissionHandler().openAppSettings();//如果没有权限 打开权限
//      }
//    }return null;
//  }
//}